package com.ptu.controller.admin;

import com.ptu.entity.Order;
import com.ptu.server.OrderServer;
import com.ptu.util.PageResult;
import com.ptu.util.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("adminOrderController")
@Tag(name = "管理员订单模块")
@RequestMapping("/admin/order")
public class OrderController {

    @Autowired
    OrderServer orderServer;

    @Operation(summary = "订单列表")
    @RequestMapping("/list")
    public Result<PageResult> list(Integer status,String paymentMethod, Integer pageNum, Integer pageSize) {
        System.out.println("分页订单");
        PageResult pageResult = orderServer.getOrderList(status, paymentMethod, pageNum, pageSize);
        return Result.success(pageResult);
    }

    @Operation(summary = "订单详情")
    @RequestMapping("/detail")
    public Result<Order> detail(Long id) {
        System.out.println("获取订单详情" +id);
        Order detail = orderServer.adminDetail(id);
        return Result.success(detail);
    }

    @Operation(summary = "取消订单")
   @RequestMapping("/cancel")
    public Result<String> cancel(Long id) {
        System.out.println("取消订单");
        orderServer.cancel(id);
        return Result.success("商家取消订单");
    }

    //发货
    @Operation(summary = "发货")
    @RequestMapping("/deliver")
    public Result<Void> deliver(Long id) {
        System.out.println("发货" +id);
        orderServer.deliver(id);
        return Result.success();
    }

    @Operation(summary = "确认退货")
    @RequestMapping("/return")
    public Result<Void> returnGoods(Long id) {
        System.out.println("确认退货");
        orderServer.returnOkGoods(id);
        return Result.success();
    }




}
